home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_weap_bazooka.cog < prev    next >
Text File  |  1999-11-15  |  7KB  |  296 lines

  1. # Jones 3D Cog Script
  2. #
  3. # weap_Bazooka.cog
  4. #
  5. # This COG controls the Bazooka.  Yeah, cool.
  6. #
  7. # [RandyT]
  8. #
  9. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  10. #
  11. # ===================================================================
  12.  
  13. symbols
  14.  
  15. message        startup
  16. message        fire
  17. message        activated
  18. message        deactivated
  19. message        selected
  20. message        deselected
  21. message        removed
  22. message        callback
  23. message        timer
  24.  
  25. keyframe    fly=gen_chicken.key                local    # Autoloaded
  26.  
  27. material    matBaz=rckt_a4bzoka_fire.mat    local    # Autoloaded
  28. material    matRkt=gen_a4sfx_rokt_flame.mat    local    # Autoloaded
  29.  
  30. sound        bang=gen_bazooka_fire.wav        local    # Autoloaded
  31. sound        pull=gen_bazooka_pull.wav        local    # Autoloaded
  32. sound        put=gen_bazooka_put.wav            local    # Autoloaded
  33. sound        cluck=mus_guybrush.wav            local    # Autoloaded
  34. sound        rktFire=gen_rocket.wav            local    # Autoloaded
  35. sound        rktLoop=gen_rocket_loop.wav        local    # Autoloaded
  36.  
  37. template    projectile=+bazooka                local    # Autoloaded
  38. template    chicken=+bazooka_chicken        local    # Autoloaded
  39. template    exhaust=+bazooka_exhaust        local    # Autoloaded
  40. template    smoke=+bazooka_smoke            local    # Autoloaded
  41. template    rocketFlame=+baz_spr_rocket        local    # Autoloaded
  42.  
  43. thing        player                            local
  44. thing        rocket=-1                        local
  45. thing        flame=-1                        local
  46. thing        sender                            local
  47. thing        curFlame                        local
  48.  
  49. flex        aimFOV=15.0                        local
  50. flex        aimMax=3.0                        local
  51. flex        fireWait=1.65                    local
  52. flex        smokeTime=0.1                    local
  53. flex        newTime=0.0                        local
  54.  
  55. int            handNode                        local
  56. int            holsterMesh                        local
  57. int            weaponNum=10                    local
  58. int            numRockets=0                    local
  59. int            flameTrack=-1                    local
  60. int            callNum                            local
  61.  
  62. int            bGuybrush=0                        local
  63.  
  64. vector        firePos                            local
  65.  
  66. end
  67.  
  68. # ===================================================================
  69.  
  70. code
  71.  
  72. startup:
  73.  
  74.     player = GetLocalPlayerThing();
  75.     handNode = GetNodeByName(player, "inrhand");
  76.     holsterMesh = GetMeshByName(player, "intorso");
  77.     bGuybrush = 0;
  78.  
  79.     if (IsThingModelName(player, "gen_in_shirt.3do"))
  80.     {
  81.         LoadHolsterModel(weaponNum, "torso_shirt_bazooka.3do");
  82.     }
  83.     else if (IsThingModelName(player, "gen_in.3do"))
  84.     {
  85.         LoadHolsterModel(weaponNum, "torso_in_bazooka.3do");
  86.     }
  87.     else
  88.     {
  89.         LoadHolsterModel(weaponNum, "torso_guy_bazooka.3do");
  90.         bGuybrush = 1;
  91.     }
  92.  
  93.     if (GetLastRifle(player) == weaponNum)
  94.     {
  95.         SetHolsterModel(player, weaponNum, holsterMesh);
  96.     }
  97.     
  98.     if (GetSenderRef() == 9999) # Call is from Guybrush cheat...
  99.     {
  100.         if (GetCurWeapon(player) == weaponNum)
  101.         {
  102.             ResetHolsterModel(player, 3);
  103.         }
  104.     }
  105.  
  106.     return;
  107.  
  108. # -------------------------------------------------------------------
  109.  
  110. fire:
  111.  
  112.     # Make sure Indy's not out of ammo
  113.     if (GetInv(player, weaponNum) < 1)
  114.     {
  115.         PlayVoiceMode(player, 123);
  116.         SelectWeapon(player, 3);
  117.         return;
  118.     }
  119.  
  120.     # Fire away...
  121.     firePos = GetThingJointPos(player, handNode);
  122.     
  123.     if (bGuybrush)
  124.     {
  125.         # Chicken away...
  126.         rocket = FireProjectile(player, chicken, bang, 65, firePos, '-10.5 0.0 0.0', 1.0, 0x120, aimFOV, aimMax);
  127.         fireWait = 3.0;
  128.  
  129.         # Make some exhaust
  130.         MaterialAnim(matBaz, 32, 0x8);
  131.         AttachThingToThingMesh(player, exhaust, GetMeshByName(player, "inrhand"));
  132.  
  133.         # Animate el pollo
  134.         PlayKey(rocket, fly, 2, 0x10, 0);
  135.  
  136.         # Cluck cluck
  137.         PlaySoundThing(cluck, rocket, 1.0, -1, -1, 0x481);
  138.     }
  139.     else
  140.     {
  141.         rocket = FireProjectile(player, projectile, bang, 65, firePos, '-10.5 0.0 0.0', 1.0, 0x120, aimFOV, aimMax);
  142.         fireWait = 1.65;
  143.         
  144.         # Make some exhaust
  145.         MaterialAnim(matBaz, 32, 0x8);
  146.         AttachThingToThingMesh(player, exhaust, GetMeshByName(player, "inrhand"));
  147.  
  148.         # Add some flame to the rocket
  149.         flame = AttachThingToThingMesh(rocket, rocketFlame, 0);
  150.         flameTrack = MaterialAnim(matRkt, 16, 0x1);
  151.                                   
  152.         # Store flame index
  153.         SetThingUserData(rocket, flame);
  154.  
  155.         # Play the rocket's sound
  156.         PlaySoundThing(rktFire, player, 1.0, 5, 20, 0x880);
  157.         PlaySoundThing(rktLoop, rocket, 1.0, 1, 90, 0x881);
  158.     
  159.         # Start the smoke trail
  160.         SetThingTimer(rocket, smokeTime);
  161.         CreateThing(smoke, rocket);
  162.  
  163.         # Store the smoke timer
  164.         SetThingUserData(flame, smokeTime);
  165.     }
  166.  
  167.     CaptureThing(rocket);
  168.     numRockets = numRockets + 1;
  169.  
  170.     ChangeInv(player, weaponNum, -1.0);
  171.     SetFireWait(player, fireWait);
  172.  
  173.     return;
  174.  
  175. # -------------------------------------------------------------------
  176.  
  177. activated:
  178.  
  179.     ActivateWeapon(player, 0.01);
  180.     return;
  181.  
  182. # -------------------------------------------------------------------
  183.  
  184. deactivated:
  185.  
  186.     DeactivateWeapon(player);
  187.     return;
  188.  
  189. # -------------------------------------------------------------------
  190.  
  191. selected:
  192.  
  193.     SetAimWait(player, 0);
  194.     SetMountWait(player, 1.67);
  195.  
  196.     SetArmedMode(player, 5);
  197.     SetCurWeapon(player, weaponNum);
  198.     SetThingFireOffset(player, '-0.003 0.065 0.01'); 
  199.  
  200.     CaptureThing(player);
  201.     PlayMode(player, 62, 0);
  202.  
  203.     return;
  204.  
  205. # -------------------------------------------------------------------
  206.  
  207. deselected:
  208.  
  209.     SetMountWait(player, 1.67);
  210.  
  211.     StopMode(player, 62, 0);
  212.  
  213.     CaptureThing(player);
  214.     PlayMode(player, 64, 0);
  215.  
  216.     SetArmedMode(player, 0);
  217.  
  218.     return;
  219.  
  220. # -------------------------------------------------------------------
  221.  
  222. removed:
  223.  
  224.     # Which rocket?
  225.     sender = GetSenderRef();
  226.  
  227.     # Make sure this ain't no chicken
  228.     if (!IsThingModelName(sender, "gen_rckt_bzooka.3do"))
  229.     {
  230.         if (IsThingModelName(sender, "gen_chicken.3do"))
  231.         {
  232.             numRockets = numRockets - 1;
  233.         }
  234.         return;
  235.     }
  236.  
  237.     # Kill the flame
  238.     DestroyThing(GetThingUserData(sender));
  239.     
  240.     numRockets = numRockets - 1;
  241.     
  242.     # If there are no more rockets, stop flame anim
  243.     if (numRockets < 1)
  244.     {
  245.         if (flameTrack != -1)
  246.         {
  247.             StopAnim(flameTrack);
  248.             flameTrack = -1;
  249.         }
  250.     }
  251.     
  252.     return;
  253.  
  254. # -------------------------------------------------------------------
  255.  
  256. callback:
  257.  
  258.     callNum = GetParam(1);
  259.     ReleaseThing(player);
  260.  
  261.     if (callNum == 28)
  262.     {
  263.         PlaySoundThing(pull, player, 1, -1, -1, 0x880);
  264.         ResetHolsterModel(player, 3);
  265.         SetWeaponModel(player, weaponNum);
  266.     }
  267.     else if (callNum == 29)
  268.     {
  269.         PlaySoundThing(put, player, 1, -1, -1, 0x880);
  270.         SetHolsterModel(player, weaponNum, holsterMesh);
  271.         ResetWeaponModel(player);
  272.     }
  273.  
  274.     return;
  275.  
  276. # -------------------------------------------------------------------
  277.  
  278. timer:
  279.  
  280.     # Which rocket?
  281.     sender = GetSenderRef();
  282.  
  283.     # Which flame?
  284.     curFlame = GetThingUserData(sender);
  285.  
  286.     # Lengthen the smoke time and store it
  287.     newTime = GetThingUserData(curFlame) + 0.008;
  288.     SetThingUserData(curFlame, newTime);
  289.  
  290.     # Smoke...
  291.     CreateThing(smoke, sender);
  292.     SetThingTimer(rocket, newTime);
  293.  
  294.     return;
  295.  
  296. end